//
//  NSDate+Utils.m
//  iOSFastWorkStateClientOC
//
//  Created by 肖兰月 on 2018/4/25.
//  Copyright © 2018年 浙江快工网络科技有限公司. All rights reserved.
//

#import "NSDate+Utils.h"

@implementation NSDate (Utils)

- (BOOL)isYesterday {
    NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 86400 * 1;
    NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval];
    return [newDate isToday];
}

- (BOOL)isToday {
    if (fabs(self.timeIntervalSinceNow) >= 60 * 60 * 24) return NO;
    return [NSDate new].day == self.day;
}

- (NSInteger)day {
    return [[[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:self] day];
}

@end
